import csv

with open('4-11.csv', 'w') as f:
    w = csv.DictWriter(f, ['name', 'age'])
    w.writeheader()
    w.writerow({'name': 'thomas', 'age':'22'})
    w.writerows([{'name': 'python', 'age':'30'}, {'name': 'java', 'age':'31'}])
